package zhou.contest11;

import java.sql.SQLException;


public class Manager {
		
	//Q1: 删除成绩最差的两个学生
	public void deleteLowScore(){
		Datebase d=new Datebase();
		d.getCon();
		d.delete("delete from homework order by score limit 2");		
		d.closePs();
		d.closeCon();
	}
	
	//Q2: 修改一个用户的密码
	public void updatePwd(){
		Datebase d=new Datebase();
		d.getCon();
		d.update("update user set pwd='888' where username='郭哲宇' and id=3");				
		d.closePs();
		d.closeCon();
		
	}
	//Q2: 修改一个用户的密码
		public void updatePwd2(String username,int id){
			Datebase d=new Datebase();
			d.getCon();
			d.read("select * from user");
			try {
				while(d.getRs().next()){
					if(d.getRs().getString("username").equals(username)&&d.getRs().getString("id").equals(id)){}
					d.update("update user set pwd='888' where username='郭哲宇' and id=3");
					
				}
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
							
			d.closePs();
			d.closeCon();
			
		}
	
	
}
